home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Suzy B Software 2
/
Suzy B Software CD-ROM 2 (1994).iso
/
extras
/
programm
/
gemfsc20
/
gemfsc20.lzh
/
GEMFBIND
/
AESCOMN.S
< prev
next >
Wrap
Text File
|
1993-03-26
|
6KB
|
153 lines
;*========================================================================
;*
;* AESFAST Public Domain GEM bindings.
;*
;* 04/06/89 v1.2
;* Added TST.W just before RTS in aes_return routine. This
;* hack keeps Laser C happy. Laser has an optimization such
;* that source code such as:
;* if (!rsrc_load(filename))
;* form_error(errno);
;* Will generate assembler code like:
;* jsr _rsrc_load
;* bne ...
;* So we have to make sure the CCR flags match the values in
;* d0 upon return. Returns through aes_do were working fine,
;* but the extra tst instruction was needed in aes_return.
;*========================================================================
;*************************************************************************
;*
;* AESCOMN - Common routines (takes the place of CRYSTAL).
;*
;*************************************************************************
;-------------------------------------------------------------------------
; Define the offsets within the AES block storage area.
;-------------------------------------------------------------------------
aespb = 0 ; 'aespb' MUST be first!...
pcontrl = 0 ; Pointer to control array
pglobal = 4 ; Pointer to global array
pintin = 8 ; Pointer to intin array
pintout = 12 ; Pointer to intout array
padrin = 16 ; Pointer to adrin array
padrout = 20 ; Pointer to adrout array
control = 24 ; Control array is next...
function = 24 ; Function code
sintin = 26 ; size of intin
sintout = 28 ; size of intout
sadrin = 30 ; size of adrin
sadrout = 32 ; size of adrout
global = 34 ; Global array, needs no further def.
globl aesblock ; export this
globl _aespb ; Export this label for C programs.
globl _aescontrol ; |v1.1: added
globl _global ; Export this label for C programs.
globl _gl_apversion ; |v1.1: added
globl _gl_apid ; Export this label for C programs.
globl _gl_apcount ; |v1.1: added
globl _gl_apid ; |v1.1: added
globl _gl_apprivate ; |v1.1: added
globl _gl_apptree ; |v1.1: added
globl _gl_ap1resv ; |v1.1: added
globl _gl_aprshdr ; |v1.8: added
globl _gl_ap2resv ; |v1.8: added
globl aes_do
globl aes_call
bss
aesblock: ; Integrated AES data block storage.
_aespb: ds.l 6 ; Room for aespb array.
_aescontrol: ds.w 5 ; Room for control array.
_global: ; Global array...
_gl_apversion: ds.w 1 ; AES version.
_gl_apcount: ds.w 1 ; AES max appl count.
_gl_apid: ds.w 1 ; Application id.
_gl_apprivate: ds.l 1 ; Application-specific data.
_gl_apptree: ds.l 1 ; Pointer to head of RSC tree.
_gl_ap1resv: ;|v1.4: (Old name retained)
_gl_aprshdr: ds.l 1 ;|v1.4: Pointer to rshdr struct.
_gl_ap2resv: ds.l 3 ; Rest of the global array.
text
;-------------------------------------------------------------------------
; aes_do - Set up AESBLOCK call trap 2, return directly to caller in
; program (do not go back to binding routine).
;
; This routine is entered via 'jmp'.
;-------------------------------------------------------------------------
aes_do:
movem.l d2/a2,-(sp)
subq.l #2,sp ; Allocate intout[1].
lea aesblock,a2 ; Load pointer to AES block,
movep.l d0,control+1(a2) ; fill in the control array (!),
move.l a1,pintin(a2) ; store the intin ptr into aespb
move.l a0,padrin(a2) ; store the adrin ptr into aespb
move.l sp,pintout(a2) ; store the intout ptr into aespb
move.l a2,d1 ; move the aespb pointer to the
move.w #$C8,d0 ; interface register, also the AES
trap #2 ; function code, call AES.
move.w (sp)+,d0 ; Return to caller with value from
movem.l (sp)+,d2/a2 ; intout[0] in d0 (& CCR matches d0).
rts
;-------------------------------------------------------------------------
; aes_return - Return values from the intout array (on the stack) to
; the variables the caller gaves us pointers to, then
; return directly to the caller of the binding.
;
; This routine is entered via 'jmp'.
;-------------------------------------------------------------------------
aes_return:
move.w 0(a6,d1.w),d0 ; 1st...intout[0] always goes to d0.
ret_loop:
addq.w #2,d1 ; Increment intout offset,
beq.b alldone ; if zero, all return values done.
move.l (a1)+,a0 ; Get pointer to return variable,
move.w 0(a6,d1.w),(a0) ; move value from intout[n] to
bra.b ret_loop ; variable pointed to by call parms.
alldone:
unlk a6 ; Undo the stack, & return intout[0]
tst.w d0 ; (insure CCR matches intout[0]) to
rts ; caller of the original binding.
;-------------------------------------------------------------------------
; AES call - Set up AESBLOCK, call trap 2, return to binding routine that
; called us. That binding routine will probably do some little
; cleanup or something, then want to exit via aes_return, above.
; On exit from this routine, we will return a pointer to the
; aes_return routine in a0, allowing the binding to do its thing
; then get out via 'jmp (a0)', saving the need for a relocatable
; reference to aes_return in the bindings.
;
; This routine is entered via 'jsr'.
;-------------------------------------------------------------------------
aes_call:
movem.l d2/a2,-(sp)
lea aesblock,a2 ; Load pointer to AES block,
movep.l d0,control+1(a2) ; fill in the control array (!),
move.l a1,pintin(a2) ; store the intin ptr into aespb
move.l a0,padrin(a2) ; store the adrin ptr into aespb
add.l a6,d1 ; build the intout ptr
move.l d1,pintout(a2) ; store it into aespb
move.l a2,d1 ; move the aespb pointer to the
move.w #$C8,d0 ; interface register, also the AES
trap #2 ; function code, call AES, return
lea aes_return(pc),a0 ; a pointer to the return routine
movem.l (sp)+,d2/a2 ; to the calling binding routine.
rts
; end of code